Class {
	#name : 'SycSourceCodeRefactoringCommandTest',
	#superclass : 'ParametrizedTestCase',
	#instVars : [
		'sycClass',
		'method',
		'pc'
	],
	#category : 'SystemCommands-MethodCommands-Tests',
	#package : 'SystemCommands-MethodCommands-Tests'
}

{ #category : 'building suites' }
SycSourceCodeRefactoringCommandTest class >> testParameters [

	"We only test classes that implement asRefactorings, since they have not implemented the new driver architecture yet"
	| foo bar |
	foo := self instanceSide >> #foo.
	bar := self instanceSide >> #bar.
	^ ParametrizedTestMatrix new
		addCase: { #sycClass -> SycExtractMethodAndOccurrencesCommand. #method -> foo. #pc -> 42 };
		addCase: { #sycClass -> SycExtractMethodCommand. #method -> foo. #pc -> 42 };
		addCase: { #sycClass -> SycInlineMethodCommand. #method -> foo. #pc -> 42 };
		addCase: { #sycClass -> SycInlineTempCommand. #method -> bar. #pc -> 43 };
		yourself
]

{ #category : 'dummy methods' }
SycSourceCodeRefactoringCommandTest >> bar [
   | x |
	x := 42.
	^ x + 24
]

{ #category : 'dummy methods' }
SycSourceCodeRefactoringCommandTest >> foo [ 
   ^ 42
]

{ #category : 'accessing' }
SycSourceCodeRefactoringCommandTest >> method: aCompiledMethod [
	method := aCompiledMethod 
]

{ #category : 'accessing' }
SycSourceCodeRefactoringCommandTest >> pc: anInteger [
	pc := anInteger 
]

{ #category : 'accessing' }
SycSourceCodeRefactoringCommandTest >> sycClass: anObject [
	sycClass := anObject
]

{ #category : 'tests' }
SycSourceCodeRefactoringCommandTest >> testAsRefactoringsHaveDefaultOptionsSet [

	| sourceNode cmd defaultOptions refactorings |
	"Every refactoring generated by the command must have all the default options defined in ReAbstractTransformation. 
	This test should not be necessary after migrating all commands to the new driver architecture."
	sourceNode := method ast sourceNodeForPC: pc.
	cmd := sycClass method: method node: sourceNode.
	refactorings := cmd asRefactorings.

	defaultOptions := ReAbstractTransformation refactoringOptions.
	refactorings do: [ :refactoring | defaultOptions associationsDo: [ :assoc | self assert: (refactoring options includesKey: assoc key) ] ]
]
